package com.zr.sms.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.sms.model.Employee;
import com.zr.sms.service.FindEmpService;
import com.zr.sms.serviceimpl.FindEmpServiceImpl;
/**
 * 更新员工
 * @author Administrator 谭笑傲
 *
 */

public class UpdateEmpServlet extends HttpServlet{
	FindEmpService findEmpService = new FindEmpServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		 req.setCharacterEncoding("utf8");
		 String ename = req.getParameter("ename");
		 String esex = req.getParameter("esex");
		 String ebirthday = req.getParameter("ebirthday");
		 String ephone = req.getParameter("ephone");
		 int esalary = Integer.parseInt(req.getParameter("esalary"));
		 int eid = Integer.parseInt(req.getParameter("eid"));

		 Employee e = new Employee(eid,ename,esex,ebirthday,ephone,esalary);	 


		 

		 int flag = findEmpService.updateEmp(e);
		 PrintWriter  pw =  resp.getWriter();
		 pw.write(String.valueOf(flag));
	}
}
